/* 
 * Copyright (c) 2019, CENTRIN.CIYUN.LTD. All rights reserved.
 */
package com.cory.admin.sys.domain.portal;

import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Joiner;

/**
 * 菜单
 * @author xiongcong
 * @date 2019-02-26
 */
@Data
@AllArgsConstructor
public class MenuVO {
    public Integer id;
    public String name;
    public String code;
    public String icon;
    public Integer msgs = 0;
    public String msgCodes = "";
    
    public String url;
    public List<MenuVO> meuns;
    
    public MenuVO(Integer id, String name, String code) {
        super();
        this.id = id;
        this.name = name;
        this.code = code;
    }
    
    public MenuVO(Integer id, String name, String code, String icon) {
        super();
        this.id = id;
        this.name = name;
        this.code = code;
        this.icon = icon;
    }
    
    public MenuVO url(String url) {
        this.url = url;
        return this;
    }
    
    public MenuVO msgCodes(String msgCodes, Integer tenantId) {
        if (StringUtils.isAnyBlank(msgCodes) || tenantId == null) {
            return this;
        }
        
        this.msgCodes = Joiner.on(" ").join(msgCodes.split(","));
        
        return this;
    }
}
